//
//  YXYStatusUser.swift
//  SinaWeibo
//
//  Created by 袁向阳 on 16/6/29.
//  Copyright © 2016年 YXY.cn. All rights reserved.
//

import UIKit

class YXYStatusUser: NSObject {
    
    //用户id
    var id: Int64 = 0
    //用户昵称
    var name: String?
    //用户头像
    var profile_image_url: String?
    /// 认证类型，-1：没有认证，0，认证用户，2,3,5: 企业认证，220: 达人
    var verified_type: Int = -1{
        didSet{
            verifiedImage = getVipImage(verified_type)
        }
        
    }
    /// 会员等级 0-6
    var mbrank: Int = 0{
        didSet{
            mbrankImage = getMbrankImage(mbrank)
        }
    }
    // 认证image
    var verifiedImage: UIImage?
    // 会员等级image
    var mbrankImage: UIImage?
    
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
    }
    
    // MARK: - 获取认证类型的图片
    private func getVipImage (verified_type: Int) -> UIImage? {
        switch verified_type {
        case 0:
            let image = UIImage(named: "avatar_vip")
            return image
        case 2,3,5:
            let image = UIImage(named: "avatar_enterprise_vip")
            return image
        case 220:
            let image = UIImage(named: "avatar_grassroot")
            return image
        default :
            let image = UIImage(named: "avatar_vgirl")
            return image
        }
    }
    // MARK: - 获取会员等级图片
    private func getMbrankImage (mbrank: Int) -> UIImage? {
        if mbrank > 0 && mbrank < 7 {
            let image = UIImage(named: "common_icon_membership_level\(mbrank)")
            return image
        }else {
            let image = UIImage(named: "common_icon_membership_expired")
            return image
        }
    }
}
